package com.s59.ch01.service;


import com.s59.ch01.entity.Department;
import com.s59.ch01.entity.Employee;
import com.s59.ch01.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceimpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<Employee> listall(String account, String realName, Integer bid, Integer pageNo, Integer pageSize) {
        List<Employee> list = userMapper.listall(account, realName, bid, pageNo, pageSize);
        list.forEach(employee -> {
            employee.setList(userMapper.listbmname(employee.getId()));
        });
        return list;
    }

    @Override
    public int count(String account, String realName, Integer bid) {
        return userMapper.count(account, realName, bid);
    }

    @Override
    public List<Department> listxlk() {
        return userMapper.listxlk();
    }

    @Override
    public int insertAll(Employee employee) {
        return userMapper.insertAll(employee);
    }

    @Override
    public int selectAccount(String account) {
        return userMapper.selectAccount(account);
    }

    @Override
    public int insertSkill(String jnname, Integer uid) {
        return userMapper.insertSkill(jnname, uid);
    }

    @Override
    public Employee select(String account) {
        return userMapper.select(account);
    }

    @Override
    public Employee select1(Integer id) {
        return userMapper.select1(id);
    }

    @Override
    public List<String> listbmname(Integer id) {
        return userMapper.listbmname(id);
    }

    @Override
    public int update(Employee employee) {
        return userMapper.update(employee);
    }

    @Override
    public int deleteskill(int id) {
        return userMapper.deleteskill(id);
    }

    @Override
    public int updateimg(Employee employee) {
        return userMapper.updateimg(employee);
    }

    @Override
    public int deleteemployee(Integer id) {
        return userMapper.deleteemployee(id);
    }


}
